package com.example.server2;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    @Autowired
    DiscoveryClient discoveryClient;

    @RequestMapping("123")
    public String hello(){
        ServiceInstance localServiceInstance = discoveryClient.getLocalServiceInstance();
        System.out.println("***" + localServiceInstance.getServiceId());
        return "hello, this is service1";
    }
}
